<?php

/*
Zoo Management Simulation
The cageProcess file manages requests sent from the Cage UI by securing doors, toggling the lighting
and sending the user to the edit form
*/

include("dbconnect.php");
if ($_REQUEST['submit'] === "Return to Administator page"){
	header('Location: index.php');
}

else if ($_REQUEST['submit'] == "Secure doors"){
	$securesql = "UPDATE `entry` SET `Entry_Status`='Closed' WHERE `Cage_Id`=".$_REQUEST['cageid'];
	$secureresult = mysql_query($securesql);
	header('Location: cage.php?cageid='.$_REQUEST['cageid'].'&cagenumber='.$_REQUEST['cagenumber'].'&lighting='.$_REQUEST['lighting']);
}

else if ($_REQUEST['submit'] == "Toggle lighting"){
	if ($_REQUEST['lighting'] == 1){
			header('Location: cage.php?cageid='.$_REQUEST['cageid'].'&cagenumber='.$_REQUEST['cagenumber'].'&lighting=0');
	}
	else if ($_REQUEST['lighting'] == 0){
			header('Location: cage.php?cageid='.$_REQUEST['cageid'].'&cagenumber='.$_REQUEST['cagenumber'].'&lighting=1');
	}
}

if ($_REQUEST['submit'] == "Edit Cage"){
	header('Location: editCage.php?cageid='.$_REQUEST['cageid'].'&cagenumber='.$_REQUEST['cagenumber']);
}
?>